package builder;

import java.util.Vector;

import model.Action;
import model.EActionType;
import model.ElementAction;
import model.RelationAction;

/**
 * 
 * @author ELTIO
 */
public abstract class AbstractPatternBuilder {
	
	protected Vector<Action> patternActions;
	protected Vector<String> names;

	public Vector<String> getNames() {
		return names;
	}

	public void setNames(Vector<String> names) {
		this.names = names;
	}

	public AbstractPatternBuilder() {
		patternActions = new Vector<Action>();
	}
	
	public void buildAbstractClass (String name) {
		patternActions.add(new ElementAction(EActionType.AbstractClass, name));
	}
	
	public void buildClass (String name) {
		patternActions.add(new ElementAction(EActionType.Class, name));
	}
	
	public void buildInterface (String name) {
		patternActions.add(new ElementAction(EActionType.Interface, name));
	}
	
	public void buildAggregation (String begin, String end) {
		patternActions.add(new RelationAction(EActionType.Aggregation, begin, end));
	}
	
	public void buildAssociation (String begin, String end) {
		patternActions.add(new RelationAction(EActionType.Association, begin, end));
	}
	
	public void buildComposition (String begin, String end) {
		patternActions.add(new RelationAction(EActionType.Composition, begin, end));
	}
	
	public void buildDependency (String begin, String end) {
		patternActions.add(new RelationAction(EActionType.Dependency, begin, end));
	}
	
	public void buildGeneralization (String begin, String end) {
		patternActions.add(new RelationAction(EActionType.Generalization, begin, end));
	}
	
	public void buildImplementation (String begin, String end) {
		patternActions.add(new RelationAction(EActionType.Implementation, begin, end));
	}
	
	public boolean checkNamesVectorSize () {
		if (names!=null) {
			if (names.size()==this.cantUMLElements()) {
				return true;
			}
		}
		return false;
	}
	
	public Vector<Action> build () {
		
		if (checkNamesVectorSize()) {
			this.changeNames();
		}
		return buildPattern();
		
	}
	
	public abstract Vector<Action> buildPattern();
	
	public abstract void changeNames();
	
	public abstract int cantUMLElements();

}
